
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>修改内核 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    
    <link rel="stylesheet" href="../../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-katex/katex.min.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-emphasize/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-codeblock-label/block.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-click-reveal/click_reveal.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-expandable-chapters-interactive/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    


    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="part-3.html" />
    
    
    <link rel="prev" href="part-1.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../../">
            
                <a href="../../../">
            
                    
                    实验简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../../notes/log.html">
            
                <a href="../../../notes/log.html">
            
                    
                    更新日志
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">实验之前</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../../pre-lab/env.html">
            
                <a href="../../pre-lab/env.html">
            
                    
                    环境部署
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../../pre-lab/gdb.html">
            
                <a href="../../pre-lab/gdb.html">
            
                    
                    GDB 调试方法*
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">实验指导</li>
        
        
    
        <li class="chapter " data-level="3.1" >
            
                <span>
            
                    
                    实验指导零
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1.1" data-path="../../lab-0/guide/intro.html">
            
                <a href="../../lab-0/guide/intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.2" data-path="../../lab-0/guide/part-1.html">
            
                <a href="../../lab-0/guide/part-1.html">
            
                    
                    创建项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.3" data-path="../../lab-0/guide/part-2.html">
            
                <a href="../../lab-0/guide/part-2.html">
            
                    
                    移除标准库依赖
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.4" data-path="../../lab-0/guide/part-3.html">
            
                <a href="../../lab-0/guide/part-3.html">
            
                    
                    移除运行时环境依赖
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.5" data-path="../../lab-0/guide/part-4.html">
            
                <a href="../../lab-0/guide/part-4.html">
            
                    
                    编译为裸机目标
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.6" data-path="../../lab-0/guide/part-5.html">
            
                <a href="../../lab-0/guide/part-5.html">
            
                    
                    生成内核镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.7" data-path="../../lab-0/guide/part-6.html">
            
                <a href="../../lab-0/guide/part-6.html">
            
                    
                    调整内存布局
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.8" data-path="../../lab-0/guide/part-7.html">
            
                <a href="../../lab-0/guide/part-7.html">
            
                    
                    重写程序入口点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.9" data-path="../../lab-0/guide/part-8.html">
            
                <a href="../../lab-0/guide/part-8.html">
            
                    
                    使用 QEMU 运行
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.10" data-path="../../lab-0/guide/part-9.html">
            
                <a href="../../lab-0/guide/part-9.html">
            
                    
                    接口封装和代码整理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.1.11" data-path="../../lab-0/guide/summary.html">
            
                <a href="../../lab-0/guide/summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.2" >
            
                <span>
            
                    
                    实验指导一
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.2.1" data-path="../../lab-1/guide/intro.html">
            
                <a href="../../lab-1/guide/intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.2" data-path="../../lab-1/guide/part-1.html">
            
                <a href="../../lab-1/guide/part-1.html">
            
                    
                    什么是中断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.3" data-path="../../lab-1/guide/part-2.html">
            
                <a href="../../lab-1/guide/part-2.html">
            
                    
                    RISC-V 中的中断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.4" data-path="../../lab-1/guide/part-3.html">
            
                <a href="../../lab-1/guide/part-3.html">
            
                    
                    程序运行状态
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.5" data-path="../../lab-1/guide/part-4.html">
            
                <a href="../../lab-1/guide/part-4.html">
            
                    
                    状态的保存与恢复
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.6" data-path="../../lab-1/guide/part-5.html">
            
                <a href="../../lab-1/guide/part-5.html">
            
                    
                    进入中断处理流程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.7" data-path="../../lab-1/guide/part-6.html">
            
                <a href="../../lab-1/guide/part-6.html">
            
                    
                    时钟中断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.8" data-path="../../lab-1/guide/summary.html">
            
                <a href="../../lab-1/guide/summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.3" >
            
                <span>
            
                    
                    实验指导二
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1" data-path="../../lab-2/guide/intro.html">
            
                <a href="../../lab-2/guide/intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.2" data-path="../../lab-2/guide/part-1.html">
            
                <a href="../../lab-2/guide/part-1.html">
            
                    
                    动态内存分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.3" data-path="../../lab-2/guide/part-2.html">
            
                <a href="../../lab-2/guide/part-2.html">
            
                    
                    物理内存探测
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.4" data-path="../../lab-2/guide/part-3.html">
            
                <a href="../../lab-2/guide/part-3.html">
            
                    
                    物理内存管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.5" data-path="../../lab-2/guide/summary.html">
            
                <a href="../../lab-2/guide/summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.4" >
            
                <span>
            
                    
                    实验指导三
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.4.1" data-path="intro.html">
            
                <a href="intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.2" data-path="part-1.html">
            
                <a href="part-1.html">
            
                    
                    从虚拟地址到物理地址
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="3.4.3" data-path="part-2.html">
            
                <a href="part-2.html">
            
                    
                    修改内核
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.4" data-path="part-3.html">
            
                <a href="part-3.html">
            
                    
                    实现页表
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.5" data-path="part-4.html">
            
                <a href="part-4.html">
            
                    
                    实现内核重映射
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.6" data-path="part-5.html">
            
                <a href="part-5.html">
            
                    
                    页面置换*
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.7" data-path="summary.html">
            
                <a href="summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.5" >
            
                <span>
            
                    
                    实验指导四
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.5.1" data-path="../../lab-4/guide/intro.html">
            
                <a href="../../lab-4/guide/intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.2" data-path="../../lab-4/guide/part-1.html">
            
                <a href="../../lab-4/guide/part-1.html">
            
                    
                    线程和进程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.3" data-path="../../lab-4/guide/part-2.html">
            
                <a href="../../lab-4/guide/part-2.html">
            
                    
                    线程的创建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.4" data-path="../../lab-4/guide/part-3.html">
            
                <a href="../../lab-4/guide/part-3.html">
            
                    
                    线程的切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.5" data-path="../../lab-4/guide/part-4.html">
            
                <a href="../../lab-4/guide/part-4.html">
            
                    
                    线程的结束
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.6" data-path="../../lab-4/guide/part-5.html">
            
                <a href="../../lab-4/guide/part-5.html">
            
                    
                    内核栈
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.7" data-path="../../lab-4/guide/part-6.html">
            
                <a href="../../lab-4/guide/part-6.html">
            
                    
                    线程调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.8" data-path="../../lab-4/guide/summary.html">
            
                <a href="../../lab-4/guide/summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.6" >
            
                <span>
            
                    
                    实验指导五
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.6.1" data-path="../../lab-5/guide/intro.html">
            
                <a href="../../lab-5/guide/intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.2" data-path="../../lab-5/guide/part-1.html">
            
                <a href="../../lab-5/guide/part-1.html">
            
                    
                    设备树
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.3" data-path="../../lab-5/guide/part-2.html">
            
                <a href="../../lab-5/guide/part-2.html">
            
                    
                    virtio
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.4" data-path="../../lab-5/guide/part-3.html">
            
                <a href="../../lab-5/guide/part-3.html">
            
                    
                    驱动和块设备驱动
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.5" data-path="../../lab-5/guide/part-4.html">
            
                <a href="../../lab-5/guide/part-4.html">
            
                    
                    文件系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.6" data-path="../../lab-5/guide/summary.html">
            
                <a href="../../lab-5/guide/summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.7" >
            
                <span>
            
                    
                    实验指导六
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.7.1" data-path="../../lab-6/guide/intro.html">
            
                <a href="../../lab-6/guide/intro.html">
            
                    
                    摘要
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.2" data-path="../../lab-6/guide/part-1.html">
            
                <a href="../../lab-6/guide/part-1.html">
            
                    
                    构建用户程序框架
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.3" data-path="../../lab-6/guide/part-2.html">
            
                <a href="../../lab-6/guide/part-2.html">
            
                    
                    打包为磁盘镜像
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.4" data-path="../../lab-6/guide/part-3.html">
            
                <a href="../../lab-6/guide/part-3.html">
            
                    
                    解析 ELF 文件并创建线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.5" data-path="../../lab-6/guide/part-4.html">
            
                <a href="../../lab-6/guide/part-4.html">
            
                    
                    实现系统调用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.6" data-path="../../lab-6/guide/part-5.html">
            
                <a href="../../lab-6/guide/part-5.html">
            
                    
                    处理文件描述符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.7" data-path="../../lab-6/guide/part-6.html">
            
                <a href="../../lab-6/guide/part-6.html">
            
                    
                    条件变量
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.8" data-path="../../lab-6/guide/summary.html">
            
                <a href="../../lab-6/guide/summary.html">
            
                    
                    小结
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">实验题</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../../lab-1/practice.html">
            
                <a href="../../lab-1/practice.html">
            
                    
                    实验一：中断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../../lab-2/practice.html">
            
                <a href="../../lab-2/practice.html">
            
                    
                    实验二：内存分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../practice.html">
            
                <a href="../practice.html">
            
                    
                    实验三：虚实地址转换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../../lab-4/practice-1.html">
            
                <a href="../../lab-4/practice-1.html">
            
                    
                    实验四（上）：线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../../lab-4/practice-2.html">
            
                <a href="../../lab-4/practice-2.html">
            
                    
                    实验四（下）：线程调度
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="../../lab-6/practice.html">
            
                <a href="../../lab-6/practice.html">
            
                    
                    实验六：系统调用
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">开发笔记</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../../format/partition.html">
            
                <a href="../../format/partition.html">
            
                    
                    文档代码划分
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../../format/doc.html">
            
                <a href="../../format/doc.html">
            
                    
                    文档格式规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../../format/code.html">
            
                <a href="../../format/code.html">
            
                    
                    代码格式规范
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../.." >修改内核</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="&#x4FEE;&#x6539;&#x5185;&#x6838;">&#x4FEE;&#x6539;&#x5185;&#x6838;</h2>
<p>&#x4E4B;&#x524D;&#x7684;&#x5185;&#x6838;&#x5B9E;&#x73B0;&#x5E76;&#x672A;&#x4F7F;&#x80FD;&#x9875;&#x8868;&#x673A;&#x5236;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#x5185;&#x6838;&#x662F;&#x76F4;&#x63A5;&#x5728;&#x7269;&#x7406;&#x5730;&#x5740;&#x7A7A;&#x95F4;&#x4E0A;&#x8FD0;&#x884C;&#x7684;&#x3002;&#x8FD9;&#x6837;&#x867D;&#x7136;&#x6BD4;&#x8F83;&#x7B80;&#x5355;&#xFF0C;&#x4F46;&#x662F;&#x4E3A;&#x4E86;&#x540E;&#x7EED;&#x80FD;&#x591F;&#x652F;&#x6301;&#x591A;&#x4E2A;&#x7528;&#x6237;&#x8FDB;&#x7A0B;&#x80FD;&#x591F;&#x5728;&#x5185;&#x6838;&#x4E2D;&#x5E76;&#x53D1;&#x8FD0;&#x884C;&#xFF0C;&#x6EE1;&#x8DB3;&#x9694;&#x79BB;&#x7B49;&#x6027;&#x8D28;&#xFF0C;&#x6211;&#x4EEC;&#x8981;&#x5148;&#x8FD0;&#x7528;&#x5B66;&#x8FC7;&#x7684;&#x9875;&#x8868;&#x77E5;&#x8BC6;&#xFF0C;&#x628A;&#x5185;&#x6838;&#x7684;&#x8FD0;&#x884C;&#x73AF;&#x5883;&#x4ECE;&#x7269;&#x7406;&#x5730;&#x5740;&#x7A7A;&#x95F4;&#x8F6C;&#x79FB;&#x5230;&#x865A;&#x62DF;&#x5730;&#x5740;&#x7A7A;&#x95F4;&#xFF0C;&#x4E3A;&#x4E4B;&#x540E;&#x7684;&#x529F;&#x80FD;&#x6253;&#x597D;&#x94FA;&#x57AB;&#x3002;</p>
<p>&#x66F4;&#x5177;&#x4F53;&#x7684;&#xFF0C;&#x6211;&#x4EEC;&#x73B0;&#x5728;&#x60F3;&#x5C06;&#x5185;&#x6838;&#x4EE3;&#x7801;&#x653E;&#x5728;&#x865A;&#x62DF;&#x5730;&#x5740;&#x7A7A;&#x95F4;&#x4E2D;&#x4EE5; 0xffffffff80200000 &#x5F00;&#x5934;&#x7684;&#x4E00;&#x6BB5;&#x9AD8;&#x5730;&#x5740;&#x7A7A;&#x95F4;&#x4E2D;&#x3002;&#x8FD9;&#x610F;&#x5473;&#x7740;&#x539F;&#x6765;&#x653E;&#x5728; 0x80200000 &#x8D77;&#x59CB;&#x5730;&#x5740;&#x7684;&#x5168;&#x90E8;&#x5185;&#x6838;&#x7ED3;&#x6784;&#x88AB;&#x5E73;&#x79FB;&#x5230;&#x4E86; 0xffffffff80200000 &#x7684;&#x5730;&#x5740;&#x4E0A;&#xFF0C;&#x5373;&#x6620;&#x5C04;&#x5173;&#x7CFB;&#x4E3A;&#xFF1A;&#x865A;&#x62DF;&#x5730;&#x5740;&#x51CF;&#x53BB;&#x504F;&#x79FB;&#x91CF; 0xffffffff00000000 &#x4E3A;&#x539F;&#x6765;&#x7684;&#x7269;&#x7406;&#x5730;&#x5740;&#x3002;&#x5F53;&#x7136;&#xFF0C;&#x8FD9;&#x79CD;&#x7EBF;&#x6027;&#x5E73;&#x79FB;&#x5E76;&#x4E0D;&#x662F;&#x552F;&#x4E00;&#x7684;&#x6620;&#x5C04;&#x65B9;&#x5F0F;&#xFF0C;&#x4F46;&#x662F;&#x81F3;&#x5C11;&#x73B0;&#x5728;&#xFF0C;&#x5185;&#x6838;&#x7684;&#x5168;&#x90E8;&#x4EE3;&#x7801;&#x548C;&#x6570;&#x636E;&#x6240;&#x5728;&#x7684;&#x865A;&#x62DF;&#x7A7A;&#x95F4;&#x548C;&#x7269;&#x7406;&#x7A7A;&#x95F4;&#x662F;&#x8FD9;&#x6837;&#x7684;&#x7EBF;&#x6027;&#x6620;&#x5C04;&#x3002;</p>
<p>&#x6240;&#x4EE5;&#x9700;&#x8981;&#x628A;&#x539F;&#x6765;&#x7684; linker script &#x548C;&#x4E4B;&#x524D;&#x5728;&#x7269;&#x7406;&#x5185;&#x5B58;&#x7BA1;&#x7406;&#x4E0A;&#x7684;&#x4E00;&#x4E9B;&#x53C2;&#x6570;&#x4FEE;&#x6539;&#x4E00;&#x4E0B;&#x3002;</p>
<p></p><p class="code-label">os/src/linker.ld</p><p></p>
<pre><code class="lang-clike">/* Linker Script &#x8BED;&#x6CD5;&#x53EF;&#x4EE5;&#x53C2;&#x89C1;&#xFF1A;http://www.scoberlin.de/content/media/http/informatik/gcc_docs/ld_3.html */

/* &#x76EE;&#x6807;&#x67B6;&#x6784; */
OUTPUT_ARCH(riscv)

/* &#x6267;&#x884C;&#x5165;&#x53E3; */
ENTRY(_start)

/* &#x6570;&#x636E;&#x5B58;&#x653E;&#x8D77;&#x59CB;&#x5730;&#x5740; */
BASE_ADDRESS = 0xffffffff80200000; /* &#x4FEE;&#x6539;&#x4E3A;&#x865A;&#x62DF;&#x5730;&#x5740; */

SECTIONS
{
    /* . &#x8868;&#x793A;&#x5F53;&#x524D;&#x5730;&#x5740;&#xFF08;location counter&#xFF09; */
    . = BASE_ADDRESS;

    /* start &#x7B26;&#x53F7;&#x8868;&#x793A;&#x5168;&#x90E8;&#x7684;&#x5F00;&#x59CB;&#x4F4D;&#x7F6E; */
    kernel_start = .;

    /* &#x52A0;&#x5165;&#x5BF9;&#x9F50; */
    . = ALIGN(4K);
    text_start = .;

    /* .text &#x5B57;&#x6BB5; */
    .text : {
        /* &#x628A; entry &#x51FD;&#x6570;&#x653E;&#x5728;&#x6700;&#x524D;&#x9762; */
        *(.text.entry)
        /* &#x8981;&#x94FE;&#x63A5;&#x7684;&#x6587;&#x4EF6;&#x7684; .text &#x5B57;&#x6BB5;&#x96C6;&#x4E2D;&#x653E;&#x5728;&#x8FD9;&#x91CC; */
        *(.text .text.*)
    }

    /* &#x52A0;&#x5165;&#x5BF9;&#x9F50; */
    . = ALIGN(4K);
    rodata_start = .;

    /* .rodata &#x5B57;&#x6BB5; */
    .rodata : {
        /* &#x8981;&#x94FE;&#x63A5;&#x7684;&#x6587;&#x4EF6;&#x7684; .rodata &#x5B57;&#x6BB5;&#x96C6;&#x4E2D;&#x653E;&#x5728;&#x8FD9;&#x91CC; */
        *(.rodata .rodata.*)
    }

    /* &#x52A0;&#x5165;&#x5BF9;&#x9F50; */
    . = ALIGN(4K);
    data_start = .;

    /* .data &#x5B57;&#x6BB5; */
    .data : {
        /* &#x8981;&#x94FE;&#x63A5;&#x7684;&#x6587;&#x4EF6;&#x7684; .data &#x5B57;&#x6BB5;&#x96C6;&#x4E2D;&#x653E;&#x5728;&#x8FD9;&#x91CC; */
        *(.data .data.*)
    }

    /* &#x52A0;&#x5165;&#x5BF9;&#x9F50; */
    . = ALIGN(4K);
    bss_start = .;

    /* .bss &#x5B57;&#x6BB5; */
    .bss : {
        /* &#x8981;&#x94FE;&#x63A5;&#x7684;&#x6587;&#x4EF6;&#x7684; .bss &#x5B57;&#x6BB5;&#x96C6;&#x4E2D;&#x653E;&#x5728;&#x8FD9;&#x91CC; */
        *(.sbss .bss .bss.*)
    }

    /* &#x7ED3;&#x675F;&#x5730;&#x5740; */
    /* &#x52A0;&#x5165;&#x5BF9;&#x9F50; */
    . = ALIGN(4K);
    kernel_end = .;
}
</code></pre>
<p>&#x9996;&#x5148;&#xFF0C;&#x5BF9;&#x4E8E; linker script&#xFF0C;&#x6211;&#x4EEC;&#x628A;&#x653E;&#x7F6E;&#x7684;&#x57FA;&#x5730;&#x5740;&#x4FEE;&#x6539;&#x4E3A;&#x4E86;&#x865A;&#x62DF;&#x5730;&#x5740;&#xFF0C;&#x53E6;&#x5916;&#x8FD8;&#x6709;&#x4E00;&#x4E9B;&#x4FEE;&#x6539;&#x662F;&#x6211;&#x4EEC;&#x628A;&#x6BCF;&#x4E2A;&#x6570;&#x636E;&#x6BB5;&#x90FD;&#x5BF9;&#x9F50;&#x5230;&#x4E86; 4KB&#xFF0C;&#x4E00;&#x4E2A; 4KB &#x7684;&#x865A;&#x62DF;&#x9875;&#x4E2D;&#x4E0D;&#x4F1A;&#x5305;&#x542B;&#x4E24;&#x4E2A;&#x6BB5;&#xFF0C;&#x8FD9;&#x610F;&#x5473;&#x7740;&#x8FD9;&#x4E2A;&#x9875;&#x7684;&#x5C5E;&#x6027;&#x662F;&#x53EF;&#x4EE5;&#x786E;&#x5B9A;&#x7684;&#x3002;&#x4E3E;&#x4E2A;&#x4F8B;&#x5B50;&#xFF0C;&#x5982;&#x679C;&#x4E0D;&#x5BF9;&#x9F50;&#x7684;&#x8BDD;&#xFF0C;&#x53EA;&#x8BFB;&#x7684; .rodata &#x548C; .data &#x6BB5;&#x53EF;&#x80FD;&#x653E;&#x5728;&#x4E00;&#x4E2A;&#x9875;&#x4E2D;&#xFF0C;&#x4F46;&#x662F;&#x9875;&#x8868;&#x4E2D;&#x9700;&#x8981;&#x5199;&#x4E0A;&#x8BF8;&#x5982;&#x662F;&#x5426;&#x53EF;&#x5199;&#x7684;&#x5C5E;&#x6027;&#xFF0C;&#x8FD9;&#x65F6;&#x5019;&#x5C31;&#x5FC5;&#x987B;&#x5206;&#x5F00;&#x624D;&#x53EF;&#x4EE5;&#x6807;&#x6CE8;&#x5C5E;&#x6027;&#x3002;</p>
<p>&#x5BF9;&#x5E94;&#x4FEE;&#x6539; <code>os/src/memory/config.rs</code> &#x4E2D;&#x7684; <code>KERNEL_END_ADDRESS</code> &#x4FEE;&#x6539;&#x4E3A;&#x865A;&#x62DF;&#x5730;&#x5740;&#x5E76;&#x52A0;&#x5165;&#x504F;&#x79FB;&#x91CF;&#xFF1A;</p>
<p></p><p class="code-label">os/src/memory/config.rs</p><p></p>
<pre><code class="lang-rust">lazy_static! {
    <span class="hljs-comment">/// &#x5185;&#x6838;&#x4EE3;&#x7801;&#x7ED3;&#x675F;&#x7684;&#x5730;&#x5740;&#xFF0C;&#x5373;&#x53EF;&#x4EE5;&#x7528;&#x6765;&#x5206;&#x914D;&#x7684;&#x5185;&#x5B58;&#x8D77;&#x59CB;&#x5730;&#x5740;</span>
    <span class="hljs-comment">/// </span>
    <span class="hljs-comment">/// &#x56E0;&#x4E3A; Rust &#x8BED;&#x8A00;&#x9650;&#x5236;&#xFF0C;&#x6211;&#x4EEC;&#x53EA;&#x80FD;&#x5C06;&#x5176;&#x4F5C;&#x4E3A;&#x4E00;&#x4E2A;&#x8FD0;&#x884C;&#x65F6;&#x6C42;&#x503C;&#x7684; static &#x53D8;&#x91CF;&#xFF0C;&#x800C;&#x4E0D;&#x80FD;&#x4F5C;&#x4E3A; const</span>
    <span class="hljs-keyword">pub</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">ref</span> KERNEL_END_ADDRESS: VirtualAddress = VirtualAddress(kernel_end <span class="hljs-keyword">as</span> usize); 
}

<span class="hljs-comment">/// &#x5185;&#x6838;&#x4F7F;&#x7528;&#x7EBF;&#x6027;&#x6620;&#x5C04;&#x7684;&#x504F;&#x79FB;&#x91CF;</span>
<span class="hljs-keyword">pub</span> <span class="hljs-keyword">const</span> KERNEL_MAP_OFFSET: usize = <span class="hljs-number">0xffff_ffff_0000_0000</span>;
</code></pre>
<p>&#x548C;&#x4E0A;&#x4E00;&#x7AE0;&#x7C7B;&#x4F3C;&#xFF0C;&#x6211;&#x4EEC;&#x4E5F;&#x5BF9;&#x865A;&#x62DF;&#x5730;&#x5740;&#x548C;&#x865A;&#x62DF;&#x9875;&#x53F7;&#x8FD9;&#x4E24;&#x4E2A;&#x7C7B;&#x8FDB;&#x884C;&#x4E86;&#x5C01;&#x88C5;&#xFF0C;&#x540C;&#x65F6;&#x4E5F;&#x652F;&#x6301;&#x4E86;&#x4E00;&#x4E9B;&#x8BF8;&#x5982; <code>VirtualAddress::from(PhysicalAddress)</code> &#x7684;&#x8F6C;&#x6362; trait&#xFF08;&#x5373;&#x4E00;&#x4E9B;&#x52A0;&#x51CF;&#x504F;&#x79FB;&#x91CF;&#x7B49;&#x64CD;&#x4F5C;&#xFF09;&#xFF0C;&#x8FD9;&#x90E8;&#x5206;&#x5B9E;&#x73B0;&#x66F4;&#x504F;&#x5411;&#x4E8E; Rust &#x8BED;&#x6CD5;&#xFF0C;&#x8FD9;&#x91CC;&#x4E0D;&#x518D;&#x8D58;&#x8FF0;&#x5B9E;&#x73B0;&#x65B9;&#x6CD5;&#xFF0C;&#x60F3;&#x53BB;&#x4E86;&#x89E3;&#x5B9E;&#x73B0;&#x65F6;&#x53EF;&#x4EE5;&#x53C2;&#x8003; <code>os/src/memory/address.rs</code>&#x3002;</p>
<p>&#x6700;&#x540E;&#x4E00;&#x6B65;&#xFF0C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x544A;&#x8BC9; RISC-V CPU &#x6211;&#x4EEC;&#x505A;&#x4E86;&#x8FD9;&#x4E9B;&#x4FEE;&#x6539;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x9700;&#x8981;&#x5728;&#x542F;&#x52A8;&#x65F6;&#x3001;&#x5728;&#x8FDB;&#x5165; <code>rust_main</code> &#x4E4B;&#x524D;&#x6211;&#x4EEC;&#x8981;&#x5B8C;&#x6210;&#x4E00;&#x4E2A;&#x4ECE;&#x7269;&#x7406;&#x5730;&#x5740;&#x8BBF;&#x5B58;&#x6A21;&#x5F0F;&#x5230;&#x865A;&#x62DF;&#x8BBF;&#x5B58;&#x6A21;&#x5F0F;&#x7684;&#x8F6C;&#x6362;&#xFF0C;&#x540C;&#x65F6;&#x8FD9;&#x4E5F;&#x610F;&#x5473;&#x7740;&#xFF0C;&#x6211;&#x4EEC;&#x8981;&#x5199;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;&#x9875;&#x8868;&#xFF0C;&#x5B8C;&#x6210;&#x8FD9;&#x4E2A;&#x7EBF;&#x6027;&#x6620;&#x5C04;&#xFF1A;</p>
<p></p><p class="code-label">os/src/entry.asm</p><p></p>
<pre><code class="lang-assembly"># &#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x542F;&#x52A8;&#x65F6;&#x6240;&#x9700;&#x7684;&#x6307;&#x4EE4;&#x4EE5;&#x53CA;&#x5B57;&#x6BB5;
#
# &#x6211;&#x4EEC;&#x5728; linker.ld &#x4E2D;&#x5C06;&#x7A0B;&#x5E8F;&#x5165;&#x53E3;&#x8BBE;&#x7F6E;&#x4E3A;&#x4E86; _start&#xFF0C;&#x56E0;&#x6B64;&#x5728;&#x8FD9;&#x91CC;&#x6211;&#x4EEC;&#x5C06;&#x586B;&#x5145;&#x8FD9;&#x4E2A;&#x6807;&#x7B7E;
# &#x5B83;&#x5C06;&#x4F1A;&#x6267;&#x884C;&#x4E00;&#x4E9B;&#x5FC5;&#x8981;&#x64CD;&#x4F5C;&#xFF0C;&#x7136;&#x540E;&#x8DF3;&#x8F6C;&#x81F3;&#x6211;&#x4EEC;&#x7528; rust &#x7F16;&#x5199;&#x7684;&#x5165;&#x53E3;&#x51FD;&#x6570;
#
# &#x5173;&#x4E8E; RISC-V &#x4E0B;&#x7684;&#x6C47;&#x7F16;&#x8BED;&#x8A00;&#xFF0C;&#x53EF;&#x4EE5;&#x53C2;&#x8003; https://github.com/riscv/riscv-asm-manual/blob/master/riscv-asm.md
# %hi &#x8868;&#x793A;&#x53D6; [12,32) &#x4F4D;&#xFF0C;%lo &#x8868;&#x793A;&#x53D6; [0,12) &#x4F4D;

    .section .text.entry
    .globl _start
# &#x76EE;&#x524D; _start &#x7684;&#x529F;&#x80FD;&#xFF1A;&#x5C06;&#x9884;&#x7559;&#x7684;&#x6808;&#x7A7A;&#x95F4;&#x5199;&#x5165; $sp&#xFF0C;&#x7136;&#x540E;&#x8DF3;&#x8F6C;&#x81F3; rust_main
_start:
    # &#x8BA1;&#x7B97; boot_page_table &#x7684;&#x7269;&#x7406;&#x9875;&#x53F7;
    lui t0, %hi(boot_page_table)
    li t1, 0xffffffff00000000
    sub t0, t0, t1
    srli t0, t0, 12
    # 8 &lt;&lt; 60 &#x662F; satp &#x4E2D;&#x4F7F;&#x7528; Sv39 &#x6A21;&#x5F0F;&#x7684;&#x8BB0;&#x53F7;
    li t1, (8 &lt;&lt; 60)
    or t0, t0, t1
    # &#x5199;&#x5165; satp &#x5E76;&#x66F4;&#x65B0; TLB
    csrw satp, t0
    sfence.vma

    # &#x52A0;&#x8F7D;&#x6808;&#x5730;&#x5740;
    lui sp, %hi(boot_stack_top)
    addi sp, sp, %lo(boot_stack_top)
    # &#x8DF3;&#x8F6C;&#x81F3; rust_main
    lui t0, %hi(rust_main)
    addi t0, t0, %lo(rust_main)
    jr t0

    # &#x56DE;&#x5FC6;&#xFF1A;bss &#x6BB5;&#x662F; ELF &#x6587;&#x4EF6;&#x4E2D;&#x53EA;&#x8BB0;&#x5F55;&#x957F;&#x5EA6;&#xFF0C;&#x800C;&#x5168;&#x90E8;&#x521D;&#x59CB;&#x5316;&#x4E3A; 0 &#x7684;&#x4E00;&#x6BB5;&#x5185;&#x5B58;&#x7A7A;&#x95F4;
    # &#x8FD9;&#x91CC;&#x58F0;&#x660E;&#x5B57;&#x6BB5; .bss.stack &#x4F5C;&#x4E3A;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x542F;&#x52A8;&#x65F6;&#x7684;&#x6808;
    .section .bss.stack
    .global boot_stack
boot_stack:
    # 16K &#x542F;&#x52A8;&#x6808;&#x5927;&#x5C0F;
    .space 4096 * 16
    .global boot_stack_top
boot_stack_top:
    # &#x6808;&#x7ED3;&#x5C3E;

    # &#x521D;&#x59CB;&#x5185;&#x6838;&#x6620;&#x5C04;&#x6240;&#x7528;&#x7684;&#x9875;&#x8868;
    .section .data
    .align 12
boot_page_table:
    .quad 0
    .quad 0
    # &#x7B2C; 2 &#x9879;&#xFF1A;0x8000_0000 -&gt; 0x8000_0000&#xFF0C;0xcf &#x8868;&#x793A; VRWXAD &#x5747;&#x4E3A; 1
    .quad (0x80000 &lt;&lt; 10) | 0xcf
    .zero 507 * 8
    # &#x7B2C; 510 &#x9879;&#xFF1A;0xffff_ffff_8000_0000 -&gt; 0x8000_0000&#xFF0C;0xcf &#x8868;&#x793A; VRWXAD &#x5747;&#x4E3A; 1
    .quad (0x80000 &lt;&lt; 10) | 0xcf
    .quad 0
</code></pre>
<p>&#x56DE;&#x987E;&#x4E00;&#x4E0B;&#xFF0C;&#x5F53; OpenSBI &#x542F;&#x52A8;&#x5B8C;&#x6210;&#x4E4B;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x9762;&#x5BF9;&#x7684;&#x662F;&#x4E00;&#x4E2A;&#x600E;&#x6837;&#x7684;&#x5C40;&#x9762;&#xFF1A;</p>
<ul>
<li>&#x7269;&#x7406;&#x5185;&#x5B58;&#x72B6;&#x6001;&#x4E2D; OpenSBI &#x4EE3;&#x7801;&#x653E;&#x5728; [0x80000000,0x80200000) &#x4E2D;&#xFF0C;&#x5185;&#x6838;&#x4EE3;&#x7801;&#x653E;&#x5728;&#x4EE5; 0x80200000 &#x5F00;&#x5934;&#x7684;&#x4E00;&#x5757;&#x8FDE;&#x7EED;&#x7269;&#x7406;&#x5185;&#x5B58;&#x4E2D;&#xFF1B;</li>
<li>CPU &#x72B6;&#x6001;&#xFF1A;&#x5904;&#x4E8E; S Mode &#xFF0C;&#x5BC4;&#x5B58;&#x5668; <code>satp</code> &#x7684; <code>MODE</code> &#x5B57;&#x6BB5;&#x88AB;&#x8BBE;&#x7F6E;&#x4E3A; Bare &#x6A21;&#x5F0F;&#xFF0C;&#x5373;&#x65E0;&#x8BBA;&#x53D6;&#x6307;&#x8FD8;&#x662F;&#x8BBF;&#x5B58;&#x6211;&#x4EEC;&#x901A;&#x8FC7;&#x7269;&#x7406;&#x5730;&#x5740;&#x76F4;&#x63A5;&#x8BBF;&#x95EE;&#x7269;&#x7406;&#x5185;&#x5B58;&#x3002;PC &#x5373;&#x4E3A; 0x80200000 &#x6307;&#x5411;&#x5185;&#x6838;&#x7684;&#x7B2C;&#x4E00;&#x6761;&#x6307;&#x4EE4;&#xFF1B;</li>
<li>&#x6808;&#x6307;&#x9488;&#x5BC4;&#x5B58;&#x5668; <code>sp</code> &#x8FD8;&#x6CA1;&#x6709;&#x521D;&#x59CB;&#x5316;&#xFF0C;&#x8FD8;&#x6CA1;&#x6709;&#x6307;&#x5411; <code>boot_stack_top</code>&#xFF1B;</li>
<li>&#x4EE3;&#x7801;&#x4E2D; <code>boot_stack_top</code> &#x7B49;&#x7B26;&#x53F7;&#x7684;&#x5730;&#x5740;&#x90FD;&#x662F;&#x865A;&#x62DF;&#x5730;&#x5740;&#xFF08;&#x9AD8;&#x5730;&#x5740;&#xFF09;&#x3002;</li>
</ul>
<p>&#x800C;&#x6211;&#x4EEC;&#x9700;&#x8981;&#x505A;&#x7684;&#x5C31;&#x662F;&#xFF0C;&#x628A; CPU &#x7684;&#x8BBF;&#x95EE;&#x6A21;&#x5F0F;&#x6539;&#x4E3A; Sv39&#xFF0C;&#x8FD9;&#x91CC;&#x9700;&#x8981;&#x505A;&#x7684;&#x5C31;&#x662F;&#x628A;&#x4E00;&#x4E2A;&#x9875;&#x8868;&#x7684;&#x7269;&#x7406;&#x9875;&#x53F7;&#x548C; Sv39 &#x6A21;&#x5F0F;&#x5199;&#x5165; <code>satp</code> &#x5BC4;&#x5B58;&#x5668;&#xFF0C;&#x7136;&#x540E;&#x5237;&#x65B0; TLB&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x5148;&#x4F7F;&#x7528;&#x4E00;&#x79CD;&#x6700;&#x7B80;&#x5355;&#x7684;&#x9875;&#x8868;&#x6784;&#x9020;&#x65B9;&#x6CD5;&#xFF0C;&#x8FD8;&#x8BB0;&#x5F97;&#x4E0A;&#x4E00;&#x8282;&#x4E2D;&#x6240;&#x8BB2;&#x7684;&#x5927;&#x9875;&#x5417;&#xFF1F;&#x90A3;&#x65F6;&#x6211;&#x4EEC;&#x63D0;&#x5230;&#xFF0C;&#x5C06;&#x4E00;&#x4E2A;&#x4E09;&#x7EA7;&#x9875;&#x8868;&#x9879;&#x7684;&#x6807;&#x5FD7;&#x4F4D; <code>R,W,X</code> &#x4E0D;&#x8BBE;&#x4E3A;&#x5168; 0&#xFF0C;&#x53EF;&#x4EE5;&#x5C06;&#x5B83;&#x53D8;&#x4E3A;&#x8868;&#x793A; 1GB &#x7684;&#x4E00;&#x4E2A;&#x5927;&#x9875;&#x3002;</p>
<p>&#x90A3;&#x4E48;&#xFF0C;&#x9875;&#x8868;&#x91CC;&#x9762;&#x9700;&#x8981;&#x653E;&#x4EC0;&#x4E48;&#x6570;&#x636E;&#x5462;&#xFF1F;&#x7B2C;&#x4E8C;&#x4E2A; <code>.quad</code> &#xFF08;&#x8868;&#x4E2D;&#x7B2C; 510 &#x9879;&#xFF0C;510 &#x7684;&#x4E8C;&#x8FDB;&#x5236;&#x662F;&#x8981;&#x7D22;&#x5F15;&#x865A;&#x62DF;&#x5730;&#x5740;&#x7684; <span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>V</mi><mi>P</mi><msub><mi>N</mi><mn>3</mn></msub></mrow><annotation encoding="application/x-tex">VPN_3</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.83333em;vertical-align:-0.15em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.22222em;">V</span><span class="mord mathit" style="margin-right:0.13889em;">P</span><span class="mord"><span class="mord mathit" style="margin-right:0.10903em;">N</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.10903em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord mathrm mtight">3</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span></span></span></span>&#xFF09;&#x663E;&#x7136;&#x662F;&#x4ECE; 0xffffffff80000000 &#x5230; 0x80000000 &#x8FD9;&#x6837;&#x7684;&#x7EBF;&#x6027;&#x6620;&#x5C04;&#xFF0C;&#x540C;&#x65F6; <code>0xcf</code> &#x8868;&#x793A;&#x4E86; <code>VRWXAD</code> &#x5747;&#x4E3A; 1 &#x7684;&#x5C5E;&#x6027;&#x3002;</p>
<p>&#x89C2;&#x5BDF;&#x4E00;&#x4E0B;&#xFF0C;&#x9664;&#x4E86;&#x4E0A;&#x9762;&#x8FD9;&#x4E2A;&#x6620;&#x5C04;&#xFF0C;&#x6211;&#x4EEC;&#x7684; <code>boot_page_table</code> &#x91CC;&#x9762;&#x4E3A;&#x4EC0;&#x4E48;&#x8FD8;&#x6709;&#x4E00;&#x4E2A;&#x4ECE; 0x80000000 &#x5230; 0x80000000 &#x7684;&#x6620;&#x5C04;&#xFF1F;</p>
<div class="click_reveal"><span> Click to show </span><div><blockquote>
<p>&#x8FD9;&#x662F;&#x56E0;&#x4E3A;&#xFF0C;&#x5728;&#x8DF3;&#x8F6C;&#x5230; <code>rust_main</code> &#x4E4B;&#x524D;&#xFF08;&#x5373; <code>jr t0</code>&#xFF09;&#x4E4B;&#x524D;&#xFF0C;PC &#x7684;&#x503C;&#x90FD;&#x8FD8;&#x662F; 0x802xxxxx &#x8FD9;&#x6837;&#x7684;&#x5730;&#x5740;&#xFF0C;&#x5373;&#x4F7F;&#x662F;&#x5199;&#x5165;&#x4E86; <code>satp</code> &#x5BC4;&#x5B58;&#x5668;&#xFF0C;&#x4F46;&#x662F; PC &#x7684;&#x5730;&#x5740;&#x4E0D;&#x4F1A;&#x53D8;&#x3002;&#x4E3A;&#x4E86;&#x6267;&#x884C;&#x8FD9;&#x6BB5;&#x4E2D;&#x95F4;&#x7684;&#x5C34;&#x5C2C;&#x7684;&#x4EE3;&#x7801;&#xFF0C;&#x6211;&#x4EEC;&#x5728;&#x9875;&#x8868;&#x91CC;&#x9762;&#x4E5F;&#x9700;&#x8981;&#x52A0;&#x5165;&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x7684;&#x5730;&#x5740;&#x7684;&#x6620;&#x5C04;&#x3002;</p>
<p>&#x90A3;&#x4E3A;&#x4EC0;&#x4E48;&#x8DF3;&#x8F6C;&#x4E4B;&#x540E;&#x5C31;&#x6CA1;&#x6709;&#x95EE;&#x9898;&#x4E86;&#x5462;&#xFF1F;&#x8FD9;&#x662F;&#x56E0;&#x4E3A; <code>rust_main</code> &#x8FD9;&#x4E2A;&#x7B26;&#x53F7;&#x672C;&#x8EAB;&#x662F;&#x9AD8;&#x865A;&#x62DF;&#x5730;&#x5740;&#xFF08;&#x8FD9;&#x70B9;&#x5728; linker script &#x91CC;&#x9762;&#x5DF2;&#x7ECF;&#x4F53;&#x73B0;&#x4E86;&#xFF09;&#x3002;</p>
<p>&#x4E3A;&#x4EC0;&#x4E48;&#x6211;&#x628A;&#x8FD9;&#x4E2A;&#x6620;&#x5C04;&#x5220;&#x4E86;&#xFF0C;&#x4EE3;&#x7801;&#x8FD8;&#x662F;&#x53EF;&#x4EE5;&#x8FD0;&#x884C;&#xFF1F;&#x56E0;&#x4E3A; QEMU &#x6709;&#x6307;&#x4EE4;&#x7F13;&#x5B58;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#x8FD9;&#x6837;&#x7684;&#x5220;&#x53BB;&#x7684;&#x5199;&#x6CD5;&#x662F;&#x9519;&#x8BEF;&#x7684;&#x3002;</p>
<p>&#x8FD9;&#x4E2A;&#x5C34;&#x5C2C;&#x7684;&#x6620;&#x5C04;&#x4F1A;&#x5BF9;&#x540E;&#x9762;&#x4EA7;&#x751F;&#x9519;&#x8BEF;&#x7684;&#x5F71;&#x54CD;&#x5417;&#xFF1F;&#x4E0D;&#x4F1A;&#xFF0C;&#x56E0;&#x4E3A;&#x5728;&#x540E;&#x9762;&#xFF0C;&#x6211;&#x4EEC;&#x5C06;&#x4F7F;&#x7528; Rust &#x800C;&#x4E0D;&#x662F;&#x6C47;&#x7F16;&#x628A;&#x65B0;&#x7684;&#x9875;&#x8868;&#x52A0;&#x8F7D;&#x5230; <code>satp</code> &#x91CC;&#x9762;&#xFF0C;&#x8FD9;&#x4E2A;&#x9875;&#x8868;&#x53EA;&#x662F;&#x542F;&#x52A8;&#x65F6;&#x7684;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x9875;&#x8868;&#xFF0C;&#x6216;&#x8005;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x53EB;&#x5B83;&#x201C;&#x5185;&#x6838;&#x521D;&#x59CB;&#x6620;&#x5C04;&#x201D;&#xFF0C;&#x540E;&#x9762;&#x6211;&#x4EEC;&#x4F1A;&#x52A0;&#x5165;&#x66F4;&#x7EC6;&#x81F4;&#x7684;&#x6620;&#x5C04;&#xFF0C;&#x628A;&#x4E0D;&#x540C;&#x7684;&#x6BB5;&#x6839;&#x636E;&#x5C5E;&#x6027;&#x653E;&#x5728;&#x4E0D;&#x540C;&#x7684;&#x9875;&#x9762;&#x91CC;&#x9762;&#x3002;</p>
</blockquote>
</div></div>

<p><br></p>
<p>&#x5237;&#x65B0;&#x4E4B;&#x540E;&#xFF0C;&#x6211;&#x4EEC;&#x52A0;&#x8F7D;&#x5B8C;&#x6808;&#x5730;&#x5740;&#xFF0C;&#x5C31;&#x53EF;&#x4EE5;&#x8DF3;&#x8F6C;&#x5230; Rust &#x7F16;&#x5199;&#x7684;&#x51FD;&#x6570;&#x4E2D;&#x4E86;&#x3002;&#x81F3;&#x6B64;&#xFF0C;&#x6211;&#x53EF;&#x4EE5;&#x5728;&#x4E3B;&#x51FD;&#x6570;&#x4E2D;&#x505A;&#x4E9B;&#x7B80;&#x5355;&#x7684;&#x8F93;&#x51FA;&#xFF0C;&#x6211;&#x4EEC;&#x91CD;&#x65B0;&#x7F16;&#x8BD1;&#xFF08;cargo &#x4E0D;&#x4F1A;&#x611F;&#x77E5; linker script &#x7684;&#x53D8;&#x5316;&#xFF0C;&#x53EF;&#x80FD;&#x9700;&#x8981; <code>cargo clean</code>&#xFF09;&#x5E76;&#x8FD0;&#x884C;&#xFF0C;&#x6B63;&#x786E;&#x7684;&#x7ED3;&#x679C;&#x5E94;&#x8BE5;&#x662F;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x8FD9;&#x4E9B;&#x8F93;&#x51FA;&#xFF0C;&#x867D;&#x7136;&#x8FD9;&#x548C;&#x4E0A;&#x4E00;&#x4E2A;&#x7AE0;&#x8282;&#x7684;&#x7ED3;&#x679C;&#x770B;&#x4E0A;&#x53BB;&#x6CA1;&#x4EC0;&#x4E48;&#x4E24;&#x6837;&#xFF0C;&#x4F46;&#x662F;&#x73B0;&#x5728;&#x5185;&#x6838;&#x7684;&#x8FD0;&#x884C;&#x5DF2;&#x7ECF;&#x5728;&#x865A;&#x62DF;&#x5730;&#x5740;&#x7A7A;&#x95F4;&#x4E86;&#x3002;
<div id="page-footer" class="localized-footer"><hr><p><link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css"></p>
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
<div id="gitalk-container"></div>
<script>
    var gitalk = new Gitalk({
        clientID: "5084c46751a4b2f7cd4d",
        clientSecret: "3904f62d33aef24f19480fedc836a48b31d532e9",
        repo: "rCore-Tutorial-deploy",
        owner: "rcore-os",
        admin: [
            "chyyuu",
            "wangrunji0408",
            "xy-plus",
            "wyfcyx",
            "LyricZhao",
            "Tuyixiang"
        ],
        id: location.pathname.replace('/rCore-Tutorial-deploy', '').replace('.html', ''),
        distractionFreeMode: false
    });
    gitalk.render("gitalk-container");
</script></div></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="part-1.html" class="navigation navigation-prev " aria-label="Previous page: 从虚拟地址到物理地址">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="part-3.html" class="navigation navigation-next " aria-label="Next page: 实现页表">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"修改内核","level":"3.4.3","depth":2,"next":{"title":"实现页表","level":"3.4.4","depth":2,"path":"docs/lab-3/guide/part-3.md","ref":"docs/lab-3/guide/part-3.md","articles":[]},"previous":{"title":"从虚拟地址到物理地址","level":"3.4.2","depth":2,"path":"docs/lab-3/guide/part-1.md","ref":"docs/lab-3/guide/part-1.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["hide-element","chapter-fold","katex","alerts","emphasize","mermaid-gb3","codeblock-label","code","search-pro","click-reveal","expandable-chapters-interactive","localized-footer"],"pluginsConfig":{"chapter-fold":{},"emphasize":{},"codeblock-label":{},"search-pro":{},"search":{},"localized-footer":{"filename":"gitalk.html","hline":"true"},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":true},"hide-element":{},"katex":{},"fontsettings":{"theme":"white","family":"sans","size":1},"click-reveal":{},"highlight":{},"mermaid-gb3":{},"expandable-chapters-interactive":{},"alerts":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"docs/lab-3/guide/part-2.md","mtime":"2020-10-01T11:39:40.511Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-10-01T11:40:38.595Z"},"basePath":"../../..","book":{"language":""}});
        });
    </script>
</div>

        
    
    <script src="../../../gitbook/gitbook.js"></script>
    <script src="../../../gitbook/theme.js"></script>
    
        
        <script src="../../../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-alerts/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-mermaid-gb3/book/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-click-reveal/click_reveal.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-expandable-chapters-interactive/expandable-chapters.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    <script src="../../../gitbook/gitbook-plugin-mermaid-gb3/mermaid/mermaid.min.js"></script>

    </body>
</html>

